import fetcher from "./Fetcher";

export interface MarketAccountResponse{
    id:number
    name:string
}

export function getMarketAccountsByMarketId(marketId:number){
    return fetcher.get<MarketAccountResponse[]>(`markets/${marketId}/accounts`)
}

export function deleteMarketAccount(marketId:number,accountId:number){
    return fetcher.delete(`markets/${marketId}/accounts/${accountId}`)
}

export interface CreateMarketAccountRequest{
    name:string
}

export function addMarketAccount(marketId:number,request:CreateMarketAccountRequest){
    return fetcher.post<number>(`markets/${marketId}/accounts`, {},request)
}

export function updateMarketAccount(marketId:number,accountId:number,request:CreateMarketAccountRequest){
    return fetcher.put(`markets/${marketId}/accounts/${accountId}`,{},request)
}